package com.ming.wx;

//import lombok.AllArgsConstructor;
//import lombok.Data;
//import lombok.NoArgsConstructor;

/**
 * Create By LB on 2020/5/28.
 */
//@Data
//@AllArgsConstructor
//@NoArgsConstructor
public class RespResult<T> {

    private Integer code;
    private String message;
    private T data;

    public static <T> RespResult<T> error(RespResultEnum respResultEnum) {
        return new RespResult(respResultEnum);
    }

    public RespResult(RespResultEnum respResultEnum) {
        this.code = respResultEnum.getCode();
        this.message = respResultEnum.getMessage();
    }

    public static <T> RespResult<T> error(Integer code, String msg) {
        return new RespResult<>(code, msg);
    }

    public static <T> RespResult<T> success(T t) {
        return new RespResult(RespResultEnum.SUCCESS, t);
    }

    public RespResult(RespResultEnum respResultEnum, T data) {
        this.code = respResultEnum.getCode();
        this.message = respResultEnum.getMessage();
        this.data = data;
    }

    public RespResult(Integer code, String msg) {
        this.code = code;
        this.message = msg;
    }
}
